package ningbo.day04.basic;

import sun.text.resources.cldr.ti.FormatData_ti_ER;

/**
 * @Author 宁铂
 * @Date 2021/7/18 9:38
 * @Version 1.0
 */
public class TestFor2 {
    /** 需求：求[1,100]以内元素之和,偶数之和,偶数个数 */
    public static void main(String[] args) {
        demoFor2();
    }

    private static void demoFor2() {

        int a = 0;
        int b = 0;
        int c = 0;

        for (int i = 1; i <= 100; i++){
            a += i;

            if (i % 2 == 0){
                b += i;
                c++;
            }
        }
        System.out.println("[1,100]以内元素之和: "+a);
        System.out.println("[1,100]以内偶数之和: "+b);
        System.out.println("[1,100]以内偶数个数: "+c);
    }
}
